<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('定制客户')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">机构名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <input name="descInfo" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">客户经理：</label>
                <div class="col-sm-8">
                    <select class="form-control"  name="ownerUserId">
                        <option th:each="item:${managerInfoList}" th:value="${item.userId}" th:text="${item.username}"></option>
                    </select>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">余额：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="remainAmount" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->



            <div class="form-group">
                <label class="col-sm-3 control-label is-required">价格类型：</label>
                <div class="col-sm-8">
                    <select class="form-control"  name="priceType">
                        <option th:each="item:${priceTypeList}" th:value="${item.value}" th:text="${item.name}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">收益分成比例：</label>
                <div class="col-sm-8">
                    <input name="typeRate" class="form-control" type="text">
                    <small class="text-muted">分润类型必填，固价不必填；我方分成比例，例如：0.2(代表2/8分成，我方分成20%)</small>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">推送数量：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="pushNumber" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">推送类型：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select class="form-control"  name="singlePushFlag">-->
<!--                        <option value="1">系统推送</option>-->
<!--                        <option value="0">手动推送</option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">风控前置：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select class="form-control"  name="riskFlag">-->
<!--                        <option value="1">有风控</option>-->
<!--                        <option value="0">无风控</option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <label class="col-sm-3 control-label">机构类型：</label>
                <div class="col-sm-8">
                    <select class="form-control"  name="infoType" id="infoType">
                        <option th:each="item:${infoTypeList}" th:value="${item.value}" th:text="${item.name}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">机构联系人：</label>
                <div class="col-sm-8">
                    <input name="companyUser" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">联系电话：</label>
                <div class="col-sm-8">
                    <input name="companyPhone" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">公司名称：</label>
                <div class="col-sm-8">
                    <input name="companyName" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">公司logo：</label>
                <div class="col-sm-8">
                    <img alt="[ 公司logo ]" width="90px" height="60px"  src="" id="logoUrl_img" th:src="*{logoUrl}">
                    <input name="companyLogo" id="logoUrl" class="form-control" type="hidden" required>
                    <input id="inputImage" name="file" type="file">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">机构产品名称：</label>
                <div class="col-sm-8">
                    <input name="productName" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">最大贷款金额：</label>
                <div class="col-sm-8">
                    <input name="maxLoanAmount" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">最大利率：</label>
                <div class="col-sm-8">
                    <input name="maxRate" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">最小利率：</label>
                <div class="col-sm-8">
                    <input name="minRate" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label"></label>
                <div class="col-sm-8">
                    <button type="button"  onclick="submitHandler()" class="btn-primary btn">提交</button>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">

        var prefix = ctx + "special/info"
        $("#form-info-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/add", $('#form-info-add').serialize());
            }
        }

        $("#infoType").change(function (data) {
            var type = $("#infoType").val()
            console.log(type);
            if (type == 'API'){
                $("#apiShow").show();
            }else if(type == 'CRM') {
                $("#apiShow").hide();
            }
        });

        $(document).ready(function () {
            // 单图上传
            $("#inputImage").fileinput({
                uploadUrl: ctx + 'common/upload/specialinfo',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                var rsp = data.response;
                // log.info("return url：" + rsp.url)
                // log.info("reutrn fileName：" + rsp.fileName)
                // log.info("reutrn newFileName：" + rsp.newFileName)
                // log.info("return originalFilename：" + rsp.originalFilename)
                $("#logoUrl").val(rsp.fileUrl)
                $("#logoUrl_img").attr("src", rsp.fileUrl)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
        });

    </script>
</body>
</html>